home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performWireAdd.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  9.2 KB  |  382 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  24 April 1997
  22. //
  23. //  Description:
  24. //      This script provides an option box dialog for the wireAdd command.
  25. //
  26.  
  27. //
  28. //  Procedure Name:
  29. //      setOptionVars
  30. //
  31. //  Description:
  32. //        Initialize the option values.
  33. //
  34. //  Input Arguments:
  35. //        Whether to set the options to default values.
  36. //
  37. //  Return Value:
  38. //      None.
  39. //
  40. proc setOptionVars(int $forceFactorySettings)
  41. {
  42.     // This option box has no options since users indicated that it
  43.     // does not make sense for the wire node name to persist as a 
  44.     // preference.
  45.     //
  46.     //
  47. }
  48.  
  49. //
  50. //  Procedure Name:
  51. //      wireAddSetup
  52. //
  53. //  Description:
  54. //        Update the state of the option box UI to reflect the option values.
  55. //
  56. //  Input Arguments:
  57. //      parent               - Top level parent layout of the option box UI.
  58. //                             Required so that UI object names can be 
  59. //                             successfully resolved.
  60. //
  61. //    forceFactorySettings - Whether the option values should be set to
  62. //                             default values.
  63. //
  64. //  Return Value:
  65. //      None.
  66. //
  67. global proc wireAddSetup(string $parent, int $forceFactorySettings)
  68. {
  69.     // Retrieve the option settings
  70.     //
  71.     setOptionVars ($forceFactorySettings);
  72.  
  73.     setParent $parent;
  74.  
  75.     checkBoxGrp -edit -v1 0 wrSpec;
  76.     textFieldGrp -e -tx "" -enable 0 wrNode;
  77.     optionMenuGrp -e -enable 0 wrAddList;
  78. }
  79.  
  80. //
  81. //  Procedure Name:
  82. //      wireAddCallback
  83. //
  84. //  Description:
  85. //        Update the option values with the current state of the option box UI.
  86. //
  87. //  Input Arguments:
  88. //      parent - Top level parent layout of the option box UI.  Required so
  89. //               that UI object names can be successfully resolved.
  90. //
  91. //    doIt   - Whether the command should execute.
  92. //
  93. //  Return Value:
  94. //      None.
  95. //
  96. global proc wireAddCallback(string $parent, int $doIt)
  97. {
  98.     setParent $parent;
  99.  
  100.     // Set the optionVar's from the control values, and then perform the
  101.     // command
  102.  
  103.     if ($doIt) {
  104.         performWireAdd 0; 
  105.         addToRecentCommandQueue "performWireAdd 0" "WireAdd";
  106.     }
  107. }
  108.  
  109. //
  110. //  Procedure Name:
  111. //      wireAddOptions
  112. //
  113. //  Description:
  114. //        Construct the option box UI.  Involves accessing the standard option
  115. //        box and customizing the UI accordingly.
  116. //
  117. //  Input Arguments:
  118. //      None.
  119. //
  120. //  Return Value:
  121. //      None.
  122. //
  123. proc wireAddOptions()
  124. {
  125.     //    Name of the command for this option box.
  126.     //
  127.     string $commandName = "wireAdd";
  128.  
  129.     //    Build the option box actions.
  130.     //
  131.     string $callback = ($commandName + "Callback");
  132.     string $setup = ($commandName + "Setup");
  133.  
  134.     //    STEP 1:  Get the option box.
  135.     //    ============================
  136.     //
  137.     //    The value returned is the name of the layout to be used as
  138.     //    the parent for the option box UI.
  139.     //
  140.     string $layout = getOptionBox();
  141.     setParent $layout;
  142.     
  143.     //    STEP 2:  Pass the command name to the option box.
  144.     //    =================================================
  145.     //
  146.     //    Any default option box behaviour based on the command name is set 
  147.     //    up with this call.  For example, updating the 'Help' menu item with
  148.     //    the name of the command.
  149.     //
  150.     setOptionBoxCommandName("wire");
  151.     
  152.     //    STEP 3:  Activate the default UI template.
  153.     //    ==========================================
  154.     //
  155.     //    Activate the default UI template so that the layout of this 
  156.     //    option box is consistent with the layout of the rest of the 
  157.     //    application.
  158.     //
  159.     setUITemplate -pushTemplate DefaultTemplate;
  160.  
  161.     //    STEP 4: Create option box contents.
  162.     //    ===================================
  163.     //    
  164.     //    This, of course, will vary from option box to option box.    
  165.     
  166.     //    Turn on the wait cursor.
  167.     //
  168.     waitCursor -state 1;
  169.  
  170.     tabLayout -tabsVisible 0 -scrollable 1;
  171.     
  172.     string $parent = `columnLayout -adjustableColumn 1`;
  173.     
  174.     checkBoxGrp    
  175.         -numberOfCheckBoxes 1
  176.         -label "Specify Node"
  177.         -label1 ""
  178.         -v1 0 
  179.         -on1 "optionMenuGrp -e -enable 1 wrAddList;textFieldGrp -e -enable 1 wrNode"
  180.          -offCommand "optionMenuGrp -e -enable 0 wrAddList;textFieldGrp -e -enable 0 wrNode"
  181.         wrSpec;
  182.  
  183.     textFieldGrp -enable 0 -label "Wire Node" -tx "" wrNode;
  184.     // Create an option menu listing existing wires
  185.     //
  186.     optionMenuGrp -enable 0 -l "Existing Nodes"
  187.         -cc "textFieldGrp -e -tx `optionMenuGrp -q -v wrAddList` wrNode" 
  188.         wrAddList;
  189.  
  190.     // add all the wires to the menu
  191.     //
  192.     int $pp;
  193.     string $bnArray[];
  194.     $bnArray = `ls -type wire`;
  195.     int $bnCount = size($bnArray);
  196.     if ($bnCount > 0 ) {
  197.         for ($pp = 0; $pp < $bnCount; $pp++)
  198.         {
  199.             menuItem -l $bnArray[$pp];
  200.         }
  201.     } else {
  202.         menuItem -l "No Wires Selected";
  203.     }
  204.  
  205.     //    Turn off the wait cursor.
  206.     //
  207.     waitCursor -state 0;
  208.     
  209.     //    Step 5: Deactivate the default UI template.
  210.     //    ===========================================
  211.     //
  212.     setUITemplate -popTemplate;
  213.  
  214.     //    Step 6: Customize the buttons.  
  215.     //    ==============================
  216.     //
  217.     //    Provide more descriptive labels for the buttons.  This is not 
  218.     //    necessary, but in some cases, for example, a button labelled 
  219.     //    'Create' may be more meaningful to the user than one labelled
  220.     //    'Apply'.
  221.     //
  222.     //    Disable those buttons that are not applicable to the option box.
  223.     //
  224.     //    Attach actions to those buttons that are applicable to the option
  225.     //    box.  Note that the 'Close' button has a default action attached 
  226.     //    to it that will hide the window.  If a a custom action is
  227.     //    attached to the 'Close' button then be sure to call the 'hide the
  228.     //    option box' procedure within the custom action so that the option
  229.     //    box is hidden properly.
  230.  
  231.     //    'Apply' button.
  232.     //
  233.     string $applyBtn = getOptionBoxApplyBtn();
  234.     button -edit
  235.         -command ($callback + " " + $parent + " " + 1)
  236.         $applyBtn;
  237.  
  238.     //    'Save' button.
  239.     //
  240.     string $saveBtn = getOptionBoxSaveBtn();
  241.     button -edit 
  242.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
  243.         $saveBtn;
  244.  
  245.     //    'Reset' button.
  246.     //
  247.     string $resetBtn = getOptionBoxResetBtn();
  248.     button -edit 
  249.         -command ($setup + " " + $parent + " " + 1)
  250.         $resetBtn;
  251.  
  252.     //    Step 7: Set the option box title.
  253.     //    =================================
  254.     //
  255.     setOptionBoxTitle("Add Wire Options");
  256.  
  257.     //    Step 8: Customize the 'Help' menu item text.
  258.     //    ============================================
  259.     //
  260.     setOptionBoxHelpTag( "EditWireAdd" );
  261.  
  262.     //    Step 9: Set the current values of the option box.
  263.     //    =================================================
  264.     //
  265.     eval (($setup + " " + $parent + " " + 0));    
  266.     
  267.     //    Step 10: Show the option box.
  268.     //    =============================
  269.     //
  270.     showOptionBox();
  271. }
  272.  
  273. //
  274. //  Procedure Name:
  275. //      wireAddHelp
  276. //
  277. //  Description:
  278. //        Return a short description about this command.
  279. //
  280. //  Input Arguments:
  281. //      None.
  282. //
  283. //  Return Value:
  284. //      string.
  285. //
  286. proc string wireAddHelp()
  287. {
  288.  
  289.     return 
  290.     "  Command: wireAdd";
  291. }
  292.  
  293. //
  294. //  Procedure Name:
  295. //      assembleCmd
  296. //
  297. //  Description:
  298. //        Construct the command that will apply the option box values.
  299. //
  300. //  Input Arguments:
  301. //      None.
  302. //
  303. proc string assembleCmd()
  304. {
  305.     string $cmd;
  306.     
  307.     setOptionVars(false);
  308.  
  309.     $cmd = "doWireEdit";
  310.  
  311.     //    This is add mode = 1
  312.     
  313.     int $radio = 1;
  314.  
  315.     int $wrp=0;
  316.     if (`checkBoxGrp -exists wrSpec`) {
  317.         $wrp = `checkBoxGrp -query -v1 wrSpec`;
  318.     }
  319.     
  320.     string $wrn="\"\"";
  321.     if (`textFieldGrp -exists wrNode`) {
  322.         $wrn = `textFieldGrp -query -tx wrNode`;
  323.         if ($wrn=="") $wrn="\"\"";
  324.     }
  325.  
  326.     $cmd += (" " + $radio + " " + $wrp + " " + $wrn);
  327.     return $cmd;
  328. }
  329.  
  330. //
  331. //  Procedure Name:
  332. //      performWireAdd
  333. //
  334. //  Description:
  335. //        Perform the wireAdd command using the corresponding 
  336. //        option values.  This procedure will also show the option box
  337. //        window if necessary as well as construct the command string
  338. //        that will invoke the wireAdd command with the current
  339. //        option box values.
  340. //
  341. //  Input Arguments:
  342. //      0 - Execute the command.
  343. //      1 - Show the option box dialog.
  344. //      2 - Return the command.
  345. //
  346. global proc string performWireAdd(int $action)
  347. {
  348.     string $cmd = "";
  349.  
  350.     switch ($action) {
  351.  
  352.         //    Execute the command.
  353.         //
  354.         case 0:
  355.             //    Get the command.
  356.             //
  357.             $cmd = `assembleCmd`;
  358.  
  359.             //    Execute the command with the option settings.
  360.             //
  361.             eval($cmd);
  362.  
  363.             break;
  364.  
  365.         //    Show the option box.
  366.         //
  367.         case 1:
  368.             wireAddOptions;
  369.             break;
  370.  
  371.         //    Return the command string.
  372.         //
  373.         case 2:
  374.             //    Get the command.
  375.             //
  376.             $cmd = `assembleCmd`;
  377.             break;
  378.     }
  379.     return $cmd;
  380. }
  381.  
  382.